package org.cscarioni

import grails.test.*

class ChartValuesCalculatorServiceTests extends GrailsUnitTestCase {
    protected void setUp() {
        super.setUp()
    }

    protected void tearDown() {
        super.tearDown()
    }

    void testCalculateChart() {
		def today=new Date()
		def estimated1 = new EstimatedTimeHistoryForSprint(day: (today-1),estimatedTime:90)
		def estimated2 =new EstimatedTimeHistoryForSprint(day:today,estimatedTime:56)
		def collection = [estimated1,estimated2]
		def service=new ChartValuesCalculatorService();
		def map = service.calculateChartMap(collection);
		assertTrue(map."${(today-1).format('dd/MM/yyyy')}"==90)
		assertTrue(map."${today.format('dd/MM/yyyy')}"==56)
    }
	
	void testToZeroProgressionForDays(){
		def estimatedTime=200
		def days =4
		def service=new ChartValuesCalculatorService();
		def list = service.calculateToZeroProgressionForDays(estimatedTime,days)
		assertEquals (4, list.size())
		assertEquals (200,list[0])
		assertEquals (150,list[1])
		assertEquals (100,list[2])
		assertEquals (50,list[3])
	}
}
